? SqlBlobStore::makeAddressFromTextId( $row->old_id )
: null;
- return self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
+ $revisionText = self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
+
+ if ( $revisionText === false ) {
+ if ( isset( $row->old_id ) ) {
+ wfLogWarning( __METHOD__ . ": Bad data in text row {$row->old_id}! " );
+ } else {
+ wfLogWarning( __METHOD__ . ": Bad data in text row! " );
+ }
+ return false;
+ }
+
+ return $revisionText;
}
/**
$blob = $this->expandBlob( $row->old_text, $row->old_flags, $blobAddress );
if ( $blob === false ) {
- wfWarn( __METHOD__ . ": Bad data in text row $textId." );
+ wfLogWarning( __METHOD__ . ": Bad data in text row $textId." );
return false;
}
$blob = gzinflate( $blob );
if ( $blob === false ) {
- wfLogWarning( __METHOD__ . ': gzinflate() failed' );
+ wfWarn( __METHOD__ . ': gzinflate() failed' );
return false;
}
}
$this->testGetRevisionText( $expected, $rowData );
}
+ public function provideGetRevisionTextWithZlibExtension_badData() {
+ yield 'Generic gzip test' => [
+ 'This is a small goat of revision text.',
+ [
+ 'old_flags' => 'gzip',
+ 'old_text' => 'DEAD BEEF',
+ ],
+ ];
+ }
+
+ /**
+ * @covers Revision::getRevisionText
+ * @dataProvider provideGetRevisionTextWithZlibExtension_badData
+ */
+ public function testGetRevisionWithZlibExtension_badData( $expected, $rowData ) {
+ $this->checkPHPExtension( 'zlib' );
+ Wikimedia\suppressWarnings();
+ $this->assertFalse(
+ Revision::getRevisionText(
+ (object)$rowData
+ )
+ );
+ Wikimedia\suppressWarnings( true );
+ }
+
private function getWANObjectCache() {
return new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
}
public function testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts(
$text
) {
+ Wikimedia\suppressWarnings();
$this->assertFalse(
Revision::getRevisionText(
(object)[
]
)
);
+ Wikimedia\suppressWarnings( true );
}
/**